<?php
$dtMainIndex = new DataTable(constant('DB_TABLE_ORDER_INDEX_MAIN'));
$orderType = isset($_REQUEST['type'])?$_REQUEST['type']:false;
$orderBy = 'created';

$pageSize = 10;
$page = isset($_REQUEST['page'])?intval($_REQUEST['page']):1;
$data_list = $dtMainIndex->get_list($condition,$orderBy,$pageSize,($page - 1)*$pageSize);
$recordCount = $dtMainIndex->get_count($condition);
$pageCount = ceil($recordCount/$pageSize);
?>
<div id="mainf-3">
  <div class="tita-1" style="width:1005;">
    <h3>搜尋結果清單</h3>
  </div>
  <div class="clearfix" id="maina"><!-- start #maina //-->
  <?php foreach($data_list as $tmpData):?>
  <div class="maina-1">
    <ul>
      <li class="maina-1a">
      	<?php
      	$actionPage = 'cos.php';
      	if($tmpData['status'] == 'close')
      	{
      		$actionPage = 'cosc.php';
      	}else if($tmpData['status'] == 'cancel')
      	{
      		$actionPage = 'cosb.php';
      	}
      	?>
        姓名<img width="21" height="12" src="images/line3.gif"><a href="<?php echo $actionPage;?>?id=<?php echo $tmpData['manager_id'];?>"><?php  if($tmpData['c_name']){echo $tmpData['c_name'];}else{echo "無";};?></a></li>
      <li class="maina-1a">
        生日<img width="21" height="12" src="images/line3.gif"><?php printf("民國 %s年 %s月 %s日",$tmpData['c_birthday_year'],$tmpData['c_birthday_month'],$tmpData['c_birthday_date'])?>
      </li>
      <li class="maina-1a">
        電話<img width="21" height="12" src="images/line3.gif">(<?php echo $tmpData['c_tel_part_one'];?>)<?php echo $tmpData['c_tel_part_two'];?>
      </li>
      <li class="maina-1a">
       手機<img width="21" height="12" src="images/line3.gif"><?php echo $tmpData['c_mobile'];?>
      </li>
      <li class="maina-1a">
        E - Mail<img width="21" height="12" src="images/line3.gif"><?php echo $tmpData['c_email'];?>
      </li>
      <li class="maina-1b">
       地址<img width="21" height="12" src="images/line3.gif"><?php echo $tmpData['c_address_one'];?><?php echo $tmpData['c_address_two'];?><?php echo $tmpData['c_address_three'];?>
      </li>
    </ul>
    </div>
    <?php endforeach;?>
    
  </div><!-- end #maina //-->
  
<!-- start #pagea //-->
<?php
$linkParam = '?page=%d';
if($condition)
	$linkParam .= '&condition='.urlencode($orderType);


?>
<script language="javascript">
$(function(){
$('#pageh a').click(function(e){
var a_href= $(this).attr('href');
if ( a_href.indexOf('?') != -1) {
	a_href = a_href.substr(a_href.indexOf('?') + 1);
}
var parm_token = a_href.split('&');
var parm_len = parm_token.length;
var form = document.forms[0];
for(var i =0; i < parm_len; i++)
{
	var parm_item = parm_token[i];
	var str_token = parm_item.split('=');
	if ( form[str_token[0]] == undefined) {
		$(form).append('<input type="hidden" name="'+str_token[0]+'"/>');
	}
	$($(form).find('input[name='+str_token[0]+']')).val(str_token[1]);
	
}
form.submit();
return false;
});
});
</script>
<?php AppMain::paginationUI($pageCount,$page,$linkParam);?>
<!-- end #pagea //-->
<?php
 if(SessionUtil::isExistVar(constant('SESSION_KEY_USER_ID')) && 
				(SessionUtil::getVar(constant('SESSION_KEY_USER_IS_ADMIN')) == 'Y'
				))
				{
?>
  <!-- start #export //-->
  <form id="formexportcsv" method="post" action="exportcsv.php" target="_blank">
  <input type="hidden" name="condition" value="<?php echo base64_encode($condition);?>"/>
  <input type="hidden" name="from" value="<?php echo constant('ORDER_MENU_CURRENT_ITEM');?>"/>
<div class="mainf-4">
<ul>
     <li class="maina-1d"><a href="#" onclick="document.getElementById('formexportcsv').submit();"><img src="images/expo-btn.gif" width="81" height="29" /></a></li>
   </ul>
     </div>
<!-- end #export //-->
<?php
}
?>
</form>
</div>